<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加载动画 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/loading/loading.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 加载动画</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>⏳ 加载动画演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item">
                        <h3>Spinner</h3>
                        <div id="spinner"></div>
                    </div>

                    <div class="demo-item">
                        <h3>Dots</h3>
                        <div id="dots"></div>
                    </div>

                    <div class="demo-item">
                        <h3>Bars</h3>
                        <div id="bars"></div>
                    </div>

                    <div class="demo-item">
                        <h3>Circle</h3>
                        <div id="circle"></div>
                    </div>

                    <div class="demo-item">
                        <h3>Wave</h3>
                        <div id="wave"></div>
                    </div>

                    <div class="demo-item">
                        <h3>带文字</h3>
                        <div id="withText"></div>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/loading/loading.css"&gt;
&lt;script src="components/loading/loading.js"&lt;/script&gt;

// 2. 创建容器
&lt;div id="loadingContainer"&lt;/div&gt;

// 3. 初始化加载动画
const loading = new Loading({
    container: '#loadingContainer',
    type: 'spinner',
    size: 'medium',
    text: '加载中...'
});

// 4. 隐藏加载动画
loading.hide();

// 5. 显示加载动画
loading.show();</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/loading/loading.js"></script>
    <script>
        // Spinner
        new Loading({
            container: '#spinner',
            type: 'spinner',
            size: 'medium'
        });

        // Dots
        new Loading({
            container: '#dots',
            type: 'dots',
            size: 'medium'
        });

        // Bars
        new Loading({
            container: '#bars',
            type: 'bars',
            size: 'medium'
        });

        // Circle
        new Loading({
            container: '#circle',
            type: 'circle',
            size: 'medium'
        });

        // Wave
        new Loading({
            container: '#wave',
            type: 'wave',
            size: 'medium'
        });

        // 带文字
        new Loading({
            container: '#withText',
            type: 'spinner',
            size: 'medium',
            text: '加载中...'
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 150px;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 16px;
            color: var(--text-primary);
            width: 100%;
        }

        .btn {
            padding: 10px 16px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: var(--transition);
        }

        .btn-primary {
            background: var(--primary-color);
            color: white;
        }

        .btn-primary:hover {
            opacity: 0.9;
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: 1fr;
            }
        }
    </style>
</body>
</html>
